using Microsoft.AspNetCore.Mvc;

namespace HtmlToPdfDemo.Host.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class ValueController : ControllerBase
    {
        [HttpGet]
        public IActionResult HtmlToPdfConvert()
        {
            var Renderer = new IronPdf.ChromePdfRenderer();
            Renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
            Renderer.RenderingOptions.TextFooter.FontSize = 16;
            Renderer.RenderingOptions.TextFooter.LeftText = "{date} {time}";
            Renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";
            var htmlText = "<h1> This is Sample Pdf file</h1> <p> This is the demo for Csharp Created Pdf using IronPdf </p> <p> IronPdf is a library which provides build in functions for creating, reading <br> and manuplating pdf files with just few lines of code. </p>";
            var pdfdoc = Renderer.RenderHtmlAsPdf(htmlText);
            byte[] Binary = pdfdoc.BinaryData;
            return File(Binary, System.Net.Mime.MediaTypeNames.Application.Pdf, "Chart.pdf");
        }
    }
}